package control;

import java.awt.FileDialog;

import model.Sheet;
import model.XLBufferedReader;
import view.Gui;
import view.StatusArea;

class OpenMenuItem extends FileMenuItem {
	private Sheet sheet;
    public OpenMenuItem(Gui gui, StatusArea statusArea, Sheet sheet) {
        super(gui, statusArea, "Open");
        action = FileDialog.LOAD;
        this.sheet = sheet;
    }

    public void action(String name) {
        try {
            XLBufferedReader reader = new XLBufferedReader(name);
            reader.load(sheet.getSheet());
            sheet.update();
        } catch (Exception e) {
            statusArea.setText(e.getMessage());
        }
    }
}